import { type Request } from "express";
import { Gateway, getGateway } from "@/droplet-bus/core.define";

import { app_gateway } from "./core.local";
import { User } from "./schema.user";

export const UserGateway: Gateway = getGateway(app_gateway, "stream_user");

export interface UserInterface<T> {
  get(dto: T): Promise<{ entity: User; withSubList: User[] }>;
  getList(dto: T): Promise<{ entity: User; withSubList: User[] }>;
}

export interface UserInterfaceInServer {
  get(request: Request): Promise<{ entity: User; withSubList: User[] }>;
  getList(request: Request): Promise<{ entity: User; withSubList: User[] }>;
}

export const RefUserSubGateway: Gateway = getGateway(app_gateway, "stream_user_ref_sub");
export type postRefUserSubDto = { accountNumber: string };
export interface UserSubInterface<T> {
  /** 创建辅助账户（只能使用密码登录）*/
  postRefUserSub(dto: T & postRefUserSubDto): Promise<null>;
}

export interface UserSubInterfaceInServer {
  postRefUserSub(request: Request, dto: postRefUserSubDto): Promise<null>;
}
